<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            /* 
            其实就是同时遍历root1和root2，然后将和作为root1.val的值即可
            */
            var mergeTrees = function (root1, root2) {
                function preOrder(root1, root2) {
                    if (!root1) return root2
                    if (!root2) return root1
                    root1.val = root1.val + root2.val
                    root1.left = preOrder(root1.left, root2.left)
                    root1.right = preOrder(root1.right, root2.right)
                    return root1
                }
                return preOrder(root1, root2)
            }
        </script>
    </body>
</html>
